package com.peanut.bosskg.service.other.invoice;


import com.alibaba.fastjson.JSON;
import com.peanut.bosskg.entity.ResponseMessageVO;
import com.peanut.bosskg.entity.invoice.ApplyInvoiceRequestDTO;
import com.peanut.bosskg.entity.invoice.ApplyInvoiceResponseDTO;
import com.peanut.bosskg.enums.FunCodeEnum;
import com.peanut.bosskg.service.BaseService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;

/**
 * 商户申请开票
 *
 * @author peanut
 */
@Slf4j
@Service("applyInvoiceService")
@Async
public class ApplyInvoiceService extends BaseService {

    /**
     * @param funCodeEnum
     * @param applyInvoiceRequestDTO
     * @return
     * @throws Exception
     */
    public ApplyInvoiceResponseDTO doBusiness(FunCodeEnum funCodeEnum, ApplyInvoiceRequestDTO applyInvoiceRequestDTO) {
        log.info("申请开票开始:{}，{}", funCodeEnum, applyInvoiceRequestDTO);
        ResponseMessageVO responseMessage = applyYouFuByHttpPost(funCodeEnum, applyInvoiceRequestDTO);
        ApplyInvoiceResponseDTO applyInvoiceResponseDTO = JSON.parseObject(responseMessage.getResData(), ApplyInvoiceResponseDTO.class);
        log.info("申请开票结束:{}", applyInvoiceResponseDTO);
        return applyInvoiceResponseDTO;
    }
}





